#ifndef RP2INDEXBUFFER_H
#define RP2INDEXBUFFER_H

#include "Rp2Object.h"
#include "Rp2Bindable.h"

namespace Rp2
{

class IndexBuffer : public Object, public Bindable
{
	RP2_DECLARE_RTTI;
	RP2_DECLARE_NAME_ID;

public:
	IndexBuffer(int iIndexQuantity);
	IndexBuffer(const IndexBuffer* pkIBuffer);
	~IndexBuffer();

	// member access
	int GetIndexQuantity();
	int* GetData();
	const int* GetData() const;

    // Access to indices.
    int operator[] (int i) const;
    int& operator[] (int i);

    // An application might want to vary the "active quantity" of indices.
    // Use this function to do so.  It does not change the data storage,
    // only the m_iQuantity member.  The caller is responsible for saving the
    // full quantity of indices and resetting this when finished with the
    // index buffer.  The caller also should not pass in a quantity that is
    // larger than the original full quantity.
    void SetIndexQuantity (int iIQuantity);

	void SetID(int iID);
	const int GetID() const;

    // The offset into the indices is used by the renderer for drawing.  The
    // ability to set this is useful when multiple geometric primitives share
    // an index buffer, each primitive using a continguous set of indices.  In
    // this case, SetIndexQuantity and SetOffset will be called dynamically
    // during the application for each such geometric primitive.
    void SetOffset (int iOffset);
    int GetOffset () const;

	// stream for debug
	void PrintToFile(const char* acFilename);
private:
	// the index quanttiy
	int m_iIndexQuantity;

	// the resource ID
	int m_iID;

	// the index data
	int* m_aiIndex;

	// index offset
	int m_iOffset;
};

#include "Rp2IndexBuffer.inl"
typedef Pointer<IndexBuffer> IndexBufferPtr;

}


#endif